﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using ZDSoft.LMS.Core;
using ZDSoft.LMS.Service;
using NHibernate.Criterion;
using ZDSoft.LMS.Domain;
using ZDSoft.LMS.Web.Apps;
using ZDSoft.LMS.Manager;

namespace ZDSoft.LMS.Web.Controllers
{
    /// <summary>
    /// 业务跟踪
    /// </summary>
    public class TraceController : UcController
    {
        public ActionResult Index(int pageIndex = 1)
        {
            int count = 0;

            //组织查询条件
            IList<QueryConditions> conditions = new List<QueryConditions>();
            conditions.Add(new QueryConditions() { PropertyName = "TransportOrder.Status", Operator = "!=", Value = (int)TransportOrderStatus.WaitingForDispatch });
            
            //分页查询数据
            var listAll = Container.Instance.Resolve<IDeliveryFormService>().GetPaged(conditions, pageIndex, PagerHelper.PageSize, out count);
            PageList<DeliveryForm> pageList = listAll.ToPageList<DeliveryForm>(pageIndex, PagerHelper.PageSize, count);//转换为PageList集合，用于分页控件显示不同的页码
            return View(pageList);
        }

        public ActionResult Details(int ID)
        {
            TransportProvinceList();
            var tranportOrder = Container.Instance.Resolve<ITransportOrderService>().Get(ID);
            return View(tranportOrder);
        }

        private void TransportProvinceList()
        {
            ViewBag.ProvinceList = Container.Instance.Resolve<IProvinceService>().GetAll();
        }
    }
}
